package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JScrollPane;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.Mainframe;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.SimpleCMSPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.DatainputPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.GenRFCFunctionPanel;

public class GenerateRFCPanel extends SimpleCMSPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private GenRFCFunctionPanel functionPanel;
	private LayoutHelper layoutHelper;
	private DatainputPanel datainputPanel;
	private JScrollPane scrollPane;
	private Mainframe mainframe;

	public GenerateRFCPanel(String name, Mainframe parent) {
		super(name, parent);

		this.mainframe = parent;

		this.datainputPanel = new DatainputPanel(parent.getSignedInUser());

		this.functionPanel = new GenRFCFunctionPanel(this);
		this.setLayout(new BorderLayout());

		this.add(functionPanel, BorderLayout.EAST);

		this.layoutHelper = new LayoutHelper();
		this.add(layoutHelper, BorderLayout.CENTER);

	}

	public JScrollPane getScrollPane() {
		return scrollPane;
	}

	public DatainputPanel getDatainputPanel() {
		return datainputPanel;
	}

	public GenRFCFunctionPanel getFunctionPanel() {
		return functionPanel;
	}

	private class LayoutHelper extends JPanel {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		private LayoutHelper() {

			this.setPreferredSize(new Dimension(this.getWidth()
					- functionPanel.getWidth(), this.getHeight()));
			this.setLayout(new BorderLayout());
			GenerateRFCPanel.this.scrollPane = new JScrollPane(
					GenerateRFCPanel.this.datainputPanel);
			this.add(scrollPane);

		}

	}

	public Mainframe getMainframe() {
		return mainframe;
	}

}
